#ifndef DEVICEMGR_HPP
#define DEVICEMGR_HPP

#include "ConnMgr.hpp"
#include "Device.hpp"
#include "Message.hpp"

#include <memory>

#include <boost/cstdint.hpp>
#include <boost/ptr_container/ptr_map.hpp>
#include <boost/ptr_container/ptr_vector.hpp>

namespace kieper {
    class DeviceMgr {
        typedef boost::ptr_vector<ConnMgr> ConnMgrs;
    public:
        DeviceMgr();
        ~DeviceMgr();
        
        /**
         * Add the connection manager to be used by the device manager. The connection
         * manager object must be heap allocated - this method transfers its ownership to
         * the device manager. 
         */
        void addConnMgr(ConnMgr* connMgr);
        void findDevices();
        Device& getDevice(uint16_t deviceId);
        void sendToAll(Message& message);
        void startPacketProcessors();
    protected:
    private:
        DeviceMap devices_;
        ConnMgrs connMgrs_;
        uint32_t nextMsgId_;

        uint32_t getNextMsgId();
    };
}

#endif
